<!DOCTYPE meta PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<header>
<meta charset="UTF-8">
<script type="text/javascript">
	window.handleElementInIFrameInSameApp = function(msg) {
		document.getElementById("mainWindowMessageInSameApp").innerHTML = "Message From Main Widow: "
				+ msg;
	}
	window.handleElementInIFrameInSameDoamin = function(msg) {
		document.getElementById("mainWindowMessageInSameDomain").innerHTML = "Message From Main Widow: "
				+ msg;
	}

	//////
	function changeElementInMainWindowInSameApp(msg) {
		window.parent.handleElementInMainWindow("Iframe Messages")
	}

	//////Post Message
	window.addEventListener('message', function(e) {
		console.log("Receive message From Main Window: ", e.source, e.origin, e.data);
	}, false);
	function sendPostMessageToMainWindowInSameApp() {
		window.parent.postMessage('Nice to see you', 'http://h0.feitian.com:8080/app1/frametest1.html');
	}
</script> </header>
<body>
	<h6>Main window message in Same App</h6>
	<div id="mainWindowMessageInSameApp"></div>


	<h6>Main window message in Same Domain</h6>
	<div id="mainWindowMessageInSameDomain"></div>


	<input type="button" value="changeElementInMainWindowInSameApp"
		onclick="changeElementInMainWindowInSameApp(this)" />


	<input type="button" value="sendPostMessageToMainWindowInSameApp"
		onclick="sendPostMessageToMainWindowInSameApp()" />
</body>
</HTML>